<%
  #File:    /app/views/manage/folders/index.rhtml
  #Author:  Andrew Stone
  #Created: 06.01.2006
  
%>

<%=error_messages_for('folder')%>

<table style="vertical-align: top; border: 0; padding:0; margin: 0;">
  <tr>
    <td style="vertical-align: top">
<%=start_medium_div_wrapper%>
<%=start_form_tag(:action => "index")%>
  <div id="page_title">Manage Folders</div>
  <div id="medium">
    <table>
      <tbody>
        <tr>
          <td class="req_label">* Name</td>
          <td class="data">
            <%=text_field('folder','name',{:maxlength => 40,:size => 40})%>
          </td>
        </tr>
        <tr>
          <td class="req_label">* Parent Folder</td>
          <td class="data">
          <%
            fldrs = Folder.list_for_selection(@folder.id)
            if fldrs.empty?  
          %>
              No parent folders available 
          <% 
            else 
          %>
              <select id="folder_parent_id" name="folder_parent_id"> 
                <option/>
          <%
              fldrs.each do |fldr| 
          %>
                <option value="<%=fldr[:id]%>"><%=fldr[:name]%></option>
          <%
              end 
          %>
              </select>
          <%
            end
          %>
          </td>
        </tr>
      </tbody>
    </table>
    <%=hidden_field("folder","id")%>
    <div id="actions">
      <% if @folder.id %>
        <%=submit_tag("Cancel")%>
        <%=submit_tag("Delete")%>
        <%=submit_tag("Update")%>
      <% else %>
        <%=submit_tag("Create")%>
      <% end %>
    </div>
    <% 
    # Want to show top_level contents if no folder_id, otherwise show only
    # if there are contents for a valid folder id
      if @folder.id.nil? || (@folder.id && FolderContent.has_contents?(@folder.id)) %>
        <br/>
        <div class="container">
          <h3>Folder Contents</h3>
          <%=render(:partial => 'view_folders')%>
        </div>
    <% 
      end %>
  </div>
<%=end_form_tag%>
<%=end_div_wrapper%>
</td><td style="vertical-align: top">
<%=folder_tree%>
</td></tr></table>


